using MQTTnet;
using MQTTnet.Formatter;
using MQTTnet.Protocol;

namespace Digitalmes.Infrastructure.MQ.Mqtt;

public static class MqttClientSetup
{
    /// <summary>
    /// 注册 MQTT 消息队列。
    /// </summary>
    /// <param name="services"></param>
    /// <param name="configuration"></param>
    /// <param name="name"></param>
    /// <returns></returns>
    public static IServiceCollection AddMQTTnetSetup(this IServiceCollection services, IConfiguration configuration, string name = "MQTT")
    {
        services.Configure<MqttOptions>(configuration.GetSection(name));
        return services;
    }
}
